import { StatusType, type FoodTable } from '@/api/food/foodTable';
import { defineStore } from 'pinia';

export const useFoodStore = defineStore('food', {
  state: () => ({
    selectedFood: {
      cookbId: '',
      userId: '',
      adminId: '',
      cookbName: '菜谱名字',
      cuisine: '菜系',
      place: '所属地方',
      content: '做法内容',
      createTime: '创建时间',
      updateTime: '',
      status: StatusType.Allow, // 设置默认状态
      reviewedTime: '',
      recipeImg: '',
    } as FoodTable,
  }),
  getters: {
    getSelectedFood: (state) => state.selectedFood,
  },
  actions: {
    setSelectedFood(food: FoodTable) {
      this.selectedFood = food;
    },
  },
    // 持久化配置，将数据存储到 localStorage
    persist: {
        storage: localStorage,
      },
});
